home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_13_07
/
dawes
/
count1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-01
|
561b
|
27 lines
// Listing 1 - Count1 program
#include <cstring.h>
#include <iomanip.h>
#include <algo.h>
#include <map.h>
typedef map< string, long, less<string> > map_t;
int main() {
map_t ct_map;
string str;
while ( cin >> str ) {
ct_map.insert( map_t::value_type(str, 0L) );
++ct_map[str]; // increment the count
}
for ( map_t::const_iterator it = ct_map.begin();
it != ct_map.end(); ++it )
{ cout << setw(7) << (*it).second
<< " - " << (*it).first << endl; }
return EXIT_SUCCESS;
}